<?php

/**
* @copyright   (C) 2010 iJoomla, Inc. - All rights reserved.
* @license  GNU General Public License, version 2 (http://www.gnu.org/licenses/gpl-2.0.html) 
* @author  iJoomla.com webmaster@ijoomla.com
* @url   http://www.ijoomla.com/licensing/
* the PHP code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript  
* are NOT GPL, and are released under the IJOOMLA Proprietary Use License v1.0 
* More info at http://www.ijoomla.com/licensing/
*/

defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.view');

class iJoomla_SurveysViewQuestions extends JView {
	
	protected $items;
	protected $pagination;
	
	function display($tpl = null){				
		JToolBarHelper::title(JText::_('COM_SURVEYS_SURVEY'));
		JToolBarHelper::addNew('new');
		JToolBarHelper::editList('edit');
		JToolBarHelper::deleteList(JText::_("COM_SURVEYS_SURVEYS_DELETE_QUESTIONS"));
		JToolBarHelper::divider();
		JToolBarHelper::publishList();
		JToolBarHelper::unpublishList();
		JToolBarHelper::divider();
		JToolBarHelper::help('com_surveys',true);
		
		$items 	= $this->get('Items');
		$pagination = $this->get('Pagination');
		
		$this->items = $items;		
		$this->pagination = $pagination;
		
		parent::display($tpl);		
	}
	
	function getSurveysList($default){
		$result = $this->get("SurveysList");
		$return = '<select name="survey_filter" onchange="submitform()">';
		$selected = '';
		if($default == "0"){
			 $selected = ' selected="selected" ';
		}
		$return .= '<option value="0" '.$selected.' >-- '.JText::_("COM_SURVEYS_SELECT_SURVEY").' --</option>';
		foreach($result as $key=>$value){
			$selected = "";
			if($value["id"] == $default){
				$selected = ' selected="selected" ';
			}
			$return .= '<option value="'.$value["id"].'" '.$selected.' >'.$value["title"].'</option>';
		}
		$return .= "</select>";
		return $return;
	}	
	
	function getPagesList($default){
		$result = $this->get("PagesList");
		$return = '<select name="page_filter" onchange="submitform()">';
		$selected = '';
		if($default == "0"){
			 $selected = ' selected="selected" ';
		}
		$return .= '<option value="0" '.$selected.' >-- '.JText::_("COM_SURVEYS_SELECT_PAGE").' --</option>';
		foreach($result as $key=>$value){
			$selected = "";
			if($value["id"] == $default){
				$selected = ' selected="selected" ';
			}
			$return .= '<option value="'.$value["id"].'" '.$selected.' >'.$value["title"].'</option>';
		}
		$return .= "</select>";
		return $return;
	}
	
	function getQuestionType($type){
		switch($type){			
			case "1" : {
					return "Choice - One Answer (Vertical)";
					break;
					}
			case "2" : {
					return "Choice - One Answer (Horizontal)";
					break;
					}
			case "3" : {
					return "Choice - One Answer (Menu)";
					break;
					}
			case "4" : {
					return "Choice - Multiple Answers (Vertical)";
					break;
					}
			case "5" : {
					return "Choice - Multiple Answers (Horizontal)";
					break;
					}
			case "6" : {
					return "Matrix - One Answer per Row";
					break;
					}
			case "7" : {
					return "Matrix - Multiple Answers per Row";
					break;
					}
			case "8" : {
					return "Matrix - Multiple Answers per Row (Menus)";
					break;
					}
			case "9" : {
					return "Open Ended - One Line w/Prompt";
					break;
					}
			case "10" : {
					return "Open Ended - One More Line w/Prompt";
					break;
					}
			case "11" : {
					return "Open Ended - Essay";
					break;
					}
			case "12" : {
					return "Open Ended - Constant Sum";
					break;
					}
			case "13" : {
					return "Open Ended - Date and/or Time";
					break;
					}																								
		}
	}
}

?>
